package adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ecdc.soexample.App;
import com.deep_tools.ecdc.R;
import java.util.List;

import utils.ToastUtils;

public class DateAdapter extends BaseAdapter {
    private Activity context;
    private List<String> listDate;
    private String currentTime;

    public DateAdapter(Activity context, List<String> listDate, String currentTime){
        this.context=context;
        this.listDate=listDate;
        this.currentTime=currentTime;
//        ToastUtils.getToastUtilsInstance().toastCenterStrip(currentTime,context, Color.BLUE);
    }

    @Override
    public int getCount() {
        return listDate.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View paramView, ViewGroup parent) {
        View view = null;
        final DateAdapter.ViewHolder mHolder;
        if (paramView == null) {
            mHolder = new DateAdapter.ViewHolder();
            view = LayoutInflater.from(App.context).inflate(R.layout.item_date_month, null);
            mHolder.dateText=view.findViewById(R.id.text_item_date_month);
            view.setTag(mHolder);

        }else{
            view = paramView;
            mHolder = (DateAdapter.ViewHolder) view.getTag();
        }
        //        //具体数据@是否显示控件@是否显示边框
       String data= listDate.get(position).split("@")[0];
        String visibility= listDate.get(position).split("@")[1];
        String visibilityStroke= listDate.get(position).split("@")[2];
        if(visibility.equals("0")){
            mHolder.dateText.setVisibility(View.INVISIBLE);
        }else{
            mHolder.dateText.setVisibility(View.VISIBLE);

            if(visibilityStroke.equals("0")){
                mHolder.dateText.setBackgroundResource(R.drawable.circle_style6);

            }else{
                mHolder.dateText.setBackgroundResource(R.drawable.circle_style9);
            }
        }

        mHolder.dateText.setText(data);
        return view;
    }

    class ViewHolder {
        TextView dateText;
    }
}
